package com.sgam.mf.service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Transactional;

import com.sgam.mf.dao.GenericDAO;
import com.sgam.mf.helper.ProxyCurrentUser;

public class GenericServiceImpl<T, T_DAO extends GenericDAO<T>> implements
		GenericService<T, T_DAO> {

	private final T_DAO tDao;

	public GenericServiceImpl(T_DAO tDao) {
		this.tDao = tDao;
	}

	@Transactional
	public T get(Integer id, ProxyCurrentUser user) {
		return tDao.get(id);
	}

	@Transactional
	public T load(Integer id, ProxyCurrentUser user) {
		return tDao.load(id);
	}

	@Transactional
	public T update(T entity, ProxyCurrentUser user) {
		return tDao.update(entity);
	}

	@Transactional
	public void delete(T entity, ProxyCurrentUser user) {
		tDao.delete(entity);
	}

	@Transactional
	public List<T> list(ProxyCurrentUser user) {
		return tDao.list();
	}

	@Transactional
	public List<T> filter(Map<String, String[]> filtersMap, ProxyCurrentUser user) {
		return tDao.list();
	}

	@Transactional
	public void deleteById(Integer id, ProxyCurrentUser user) {
		tDao.deleteById(id);
	}

	public T_DAO gettDao() {
		return tDao;
	}

}
